package backingBean;

import java.util.ArrayList;

import model.Item;
import model.Sale;
import abstractFactory.Factory;
import dao.Sale.SaleDAO;

public class BeanSale {
	private Sale sale = new Sale();
	private BeanCarrinho bbit;
	
	public BeanCarrinho getBbit() {
		return bbit;
	}

	public void setBbit(BeanCarrinho bbitem) {
		this.bbit = bbitem;
	}

	public BeanSale() {}

	public Sale getSale() {
		return sale;
	}

	public void setSale(Sale sale) {
		this.sale = sale;
	}

	public void vender(){
		SaleDAO saleDao = Factory.getInstance("JPA").createSaleDAO();
		sale.setItems(bbit.getItens());
		saleDao.save(sale);
		sale = new Sale();
		bbit.setItens(new ArrayList<Item>());
		bbit.setItem(new Item());			
	}
}